package com.raidpoints.client;

import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.Button;

public class ContactBox extends DialogBox {
	RaidPoints rp;
	public ContactBox(RaidPoints mrp) {
		rp = mrp;
		setHTML("Contact Admin");
		
		LayoutPanel layoutPanel = new LayoutPanel();
		setWidget(layoutPanel);
		layoutPanel.setSize("356px", "204px");
		
		Label lblSendMessageTo = new Label("Send message to site admins. Use this form to submit bug reports, feature requests, character name change petitions, etc.");
		layoutPanel.add(lblSendMessageTo);
		layoutPanel.setWidgetLeftWidth(lblSendMessageTo, 12.0, Unit.PX, 330.0, Unit.PX);
		layoutPanel.setWidgetTopHeight(lblSendMessageTo, 10.0, Unit.PX, 50.0, Unit.PX);
		
		final TextArea textArea = new TextArea();
		textArea.setWidth("330px");
		layoutPanel.add(textArea);
		layoutPanel.setWidgetLeftWidth(textArea, 12.0, Unit.PX, 350.0, Unit.PX);
		layoutPanel.setWidgetTopHeight(textArea, 66.0, Unit.PX, 90.0, Unit.PX);
		
		Button submitButton = new Button("Submit");
		layoutPanel.add(submitButton);
		layoutPanel.setWidgetLeftWidth(submitButton, 38.0, Unit.PX, 81.0, Unit.PX);
		layoutPanel.setWidgetTopHeight(submitButton, 162.0, Unit.PX, 28.0, Unit.PX);
		
		Button cancelButton = new Button("Cancel");
		layoutPanel.add(cancelButton);
		layoutPanel.setWidgetLeftWidth(cancelButton, 218.0, Unit.PX, 81.0, Unit.PX);
		layoutPanel.setWidgetTopHeight(cancelButton, 162.0, Unit.PX, 28.0, Unit.PX);
		
		cancelButton.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				hide();
			}
		});
		
		submitButton.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				rp.rpsvc.ContactAdmin(textArea.getText(),rp.stringCallback);
				hide();
				Window.alert("Message Sent");
			}
		});
	}
}
